{extend name="common/head"/}
<link rel="stylesheet" href="{__ADMIN__}/js/jquery-tagsinput/jquery.tagsinput.min.css">
<link href="{__ADMIN__}/css/style.min.css" rel="stylesheet">
{block name="body"}
<div class="container-fluid p-t-15">

	<div class="row">
		<div class="col-lg-12">
			<div class="card">
				<div class="card-body">

					<form onsubmit="return false" action="#!" method="post" class="row" id="form1">
						<input type="hidden" value="{$id}" name="id">
						<div class="form-group col-md-12">
							<label for="title">Token签发组织</label>
							<input type="text" class="form-control" id="iss" name="iss" {notempty name="$config.iss"} value="{$config.iss}" {/notempty} placeholder="请输入签发组织" />
						</div>
						<div class="form-group col-md-12">
							<label for="title">Token签发作者</label>
							<input type="text" class="form-control" id="aud" name="aud" {notempty name="$config.aud"} value="{$config.aud}" {/notempty} placeholder="请输入签发作者" />
						</div>
						<div class="form-group col-md-12">
							<label for="title">Token Secrect</label>
							<input type="text" class="form-control" id="secrect" name="secrect" {notempty name="$config.secrect"} value="{$config.secrect}" {/notempty} placeholder="请输入secrect" />
						</div>
						<div class="form-group col-md-12">
							<label for="title">Token过期时间</label>
							<input type="text" class="form-control" id="exptime" name="exptime" {notempty name="$config.exptime"} value="{$config.exptime}" {/notempty} placeholder="请输入过期时间" />
						</div>
						<div class="form-group col-md-12">
							<button type="submit" class="btn btn-primary ajax-post" target-form="add-form" onclick="add()">确 定</button>
							<button type="submit" class="btn btn-primary ajax-post" target-form="add-form" onclick="testReg()">Api测试注册</button>
							<button type="submit" class="btn btn-primary ajax-post" target-form="add-form" onclick="testLogin()">Api测试登录</button>
							<button type="submit" class="btn btn-primary ajax-post" target-form="add-form" onclick="testToken()">Token测试</button>
						</div>
					</form>

				</div>
			</div>
		</div>

	</div>

</div>
{/block}
{block name="script"}
{include file="common/footer" base="base" /}
<!--标签插件-->
<script src="{__ADMIN__}/js/jquery-tagsinput/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="{__ADMIN__}/js/main.min.js"></script>
<script type="text/javascript">
	function add() {
		$.ajax({
			//几个参数需要注意一下
			type: "POST",//方法类型
			dataType: "json",//预期服务器返回的数据类型
			url: "/admin/conf/conf_submit" ,//url
			data: $('#form1').serialize(),
			success: function (res) {
				console.log(res);//打印服务端返回的数据(调试用)
				if (res.code === 0) {
					$.alert({
						title: '成功',
						icon: 'mdi mdi-alert',
						type: 'blue',
						content: res.msg,
						buttons: {
							okay: {
								text: '确认',
								btnClass: 'btn-blue',
								action: function() {
									location.reload();
								}
							}
						}
					});
					// setTimeout(function() {
					//     //	parent.document.location.reload();
					//     parent.document.location.href="{:url('/admin/index')}";
					// }, 1500);
				}else {
					$.alert({
						title: '错误',
						icon: 'mdi mdi-alert',
						type: 'red',
						content: res.msg,
						buttons: {
							okay: {
								text: '确认',
								btnClass: 'btn-blue',
								action: function() {
									//$('[alt="captcha"]').click();
								}
							}
						}
					});
				};
			},
			error : function() {
				$.alert({
					title: '警告',
					content: '请检查返回是否正常！',
					icon: 'mdi mdi-access-point-network-off',
					animation: 'scale',
					closeAnimation: 'scale',
					buttons: {
						okay: {
							text: '确认',
							btnClass: 'btn-blue'
						}
					}
				});
			}
		});
	}
</script>
{/block}
</body>
</html>